<font class=color size="3"><strong>收件箱</strong></font><br/>
<input type="button" value="删除" onclick="if (confirm('您确定删除本记录吗?')){ document.forms[0].submit(); }" class="submit">
<% form_tag :action => 'destroy' do %>
<table id='table' border="1" cellpadding="2" cellspacing="0" bordercolor="#666666" width=100%>
  <tr class="exebar">
    <th>新</th>
    <th><%= check_box_tag "select_all", "1", false, :onclick=>"selectall(form, 'email[]');"%></th>
    <th>发送人</th>
    <th width=50%>消息标题</th>
    <th>收件人</th>
    <th>发送时间</th>
  </tr>

<%index=1%>  
<% for email in @emails %>
  <%=ColorRow(index, email.id)%>
    <% if @read_tag[email.id] ==1 || email.readuser_ids.include?(session[:user_id])%>
        <td></td>
    <% else %>
        <td>*</td>
    <% end %>    
    <td align='center'><%= check_box_tag "email[]", email.id, false%></td>
    <td height=24><%=link_to YtwgUser.find(email.from_id).truename, :action=>"show", :id=>email, :page=>params[:page]%></td>
    <td><%= link_to email.title||"无标题", :action=>"show", :id=>email%></td>
    <% if email.recv.index(',') %>
        <td><%=email.recv[0,email.recv.index(',')] + "..." %></td>
    <% else %>
        <td><%=email.recv%></td>
    <% end %>
    <td><%=email.sendtime.strftime("%m月%d日 %H点%M分") rescue nil%></td>
   </tr>
  <%index+=1%>
<% end %>
</table>

<% end %>

 <%= will_paginate @emails %>

<script>
  function selectall(form, tagname)
    {
        if ($("select_all").checked)
        {
            for(var i=0; i<form.elements.length; i++)
            {
                 if (form.elements[i].name == tagname)
                    form.elements[i].checked = true;
            }                          
        }
        else
        {
            for(var i=0; i<form.elements.length; i++)
            {
                 if (form.elements[i].name == tagname)
                     form.elements[i].checked = false;
            }
        }
    }
</script>